﻿#pragma execution_character_set("utf-8")
#include "GameRole.h"
#include <QDebug>


GameRole::GameRole()
{

}

void GameRole::stateDisplay()
{
    qDebug() << QString("角色当前状态：");
    qDebug() << QString("体力：%1").arg(m_hp);
    qDebug() << QString("攻击力：%1").arg(m_atk);
    qDebug() << QString("防御力：%1").arg(m_def);
    qDebug() << "";
}

void GameRole::getInitState()
{
    m_hp = 100;
    m_atk = 100;
    m_def = 100;
}

void GameRole::fight()
{
    m_hp = 0;
    m_atk = 0;
    m_def = 0;
}

shared_ptr<RoleStateMemento> GameRole::saveState()
{
    return shared_ptr<RoleStateMemento>(new RoleStateMemento(m_hp, m_atk, m_def));
}

void GameRole::recoveryState(shared_ptr<RoleStateMemento> memento)
{
    m_hp = memento->getHp();
    m_atk = memento->getAtk();
    m_def = memento->getDef();
}

int GameRole::getHp() const
{
    return m_hp;
}

void GameRole::setHp(int hp)
{
    m_hp = hp;
}

int GameRole::getAtk() const
{
    return m_atk;
}

void GameRole::setAtk(int atk)
{
    m_atk = atk;
}

int GameRole::getDef() const
{
    return m_def;
}

void GameRole::setDef(int def)
{
    m_def = def;
}
